/** 
 *  @file
 *  @brief   集中质量单元
 *  @author  yuanchenxi
 *  @date    2024.05.21
 *  @version v1.0
 *  @par Copyright(c):  ShenGong  Simulation corporation
 */

#pragma once
#include "Utility/Algebra/Matrix.h"
#include "DataStructure/Common/Out.h"
#include "DataStructure/Input/Node/NodeData.h"
#include "DataStructure/Input/Element/CONM1Data.h"
#include "../Interface/IElementCalculator.h"

SG_FEMSOLVER_ELEMENT_NAMESPACE_OPEN
/** @brief 集中质量单元1（CONM1）矩阵计算类
 * 
 * 单元具有 1 个节点，每个节点具有 6 × 6 个质量系数。
 */
class ElementCalculator_DECLSPEC Conm1ElementCalculator : public SG::FEMSolver::Element::IElementCalculator
{
public:
    Conm1ElementCalculator () = default;
    virtual ~Conm1ElementCalculator () = default;

    /** @brief 计算位移输出坐标系单元质量矩阵
     * 
     * @param [in]  node    节点数据
     * @param [in]  element 单元数据
     * @param [out] mass    位移输出坐标系单元质量矩阵
     */
    static void ComputeMass
    (
    const SG::DataStructure::FEM::CONM1Data& element,
    const SG::DataStructure::FEM::NodeData&  node,
    _OUT SG::Algebra::Matrixd&               mass
    );

    virtual void Initialize (SG::DataStructure::FEM::ElementTypes type) override;
    virtual void ComputeElementMatries (const SG::DBManager::DBServiceFactorySP dbServiceFactory) override;
    virtual void DataRecovery (const SG::DBManager::DBServiceFactorySP dbServiceFactory, int subcaseId, SG::DataStructure::Common::Real time, const std::vector<SG::DataStructure::Common::Real>& globalDisplacement) override {};
    virtual void ComputeStressStiffness (const SG::DBManager::DBServiceFactorySP dbServiceFactory, int staticSubId) override {};

    static ElementCalculatorSP Create () {return std::make_shared<Conm1ElementCalculator> ();}

private:
    SG::DataStructure::FEM::ElementTypes m_type;
};

SG_FEMSOLVER_ELEMENT_NAMESPACE_CLOSE